package com.coder.test;

import com.coder.rabbit.RabbitApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @BelongsProject:coder_parent
 * @BelongsPackage:com.coder.test
 * @Author:linchong
 * @CreateTime:2019-01-07 16:35
 * @Description:
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RabbitApplication.class)
public class Producer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //直接模式
    @Test
    public void sendMsg1(){
        rabbitTemplate.convertAndSend("linchong","测试直接模式");
    }

    //分裂模式
    @Test
    public void sendMsg2(){
       rabbitTemplate.convertAndSend("rabbit","","测试分裂模式");
    }

    //主题模式
    @Test
    public void sendMsg3(){
        rabbitTemplate.convertAndSend("topic1","good.abc","测试主题模式");
    }
}
